/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */
package com.sys.midware.hbase.hcore.Optimize;


/**
 * hbase查询参数优化
 * <b>ClassName：</b> QueryOptimze <br/>
 * <b>Description：</b> TODO <br/>
 * <b>@author：</b> mobing <br/>
 * <b>@date：</b> 2015年10月26日 下午6:30:52 <br/>
 * <b>@version: </b>  <br/>
 */
public class QueryOptimze {

        // 查询优化参数
        private int numScannerCaching = -1;// 每次RPC的恳求记录数,配置已经在hbase-site.xml

        private byte[] familyReturn = null;// 指定返回的列簇

        private byte[] qualifierReturn = null;// 指定返回的列，配合familyReturn使用

        private long maxResultSize = -1;// 最大返回结果集

        private int batch = -1; // 指定最多返回的Cell数目。用于防止一行中有过多的数据，导致OutofMemory错误

        /**
         * For scans used with MapReduce jobs, this should be false. For
         * frequently accessed rows, it is advisable to use the block
         * cache.hfile.block.cache.size configured
         */

        private boolean enableBlockCache = false;

        public QueryOptimze(int numScannerCaching, byte[] familyReturn, byte[] qualifierReturn, long maxResultSize,
                int batch, boolean enableBlockCache) {
            super();
            this.numScannerCaching = numScannerCaching;
            this.familyReturn = familyReturn;
            this.qualifierReturn = qualifierReturn;
            this.maxResultSize = maxResultSize;
            this.batch = batch;
            this.enableBlockCache = enableBlockCache;
        }

        /**
         * 默认优化
         */
        public QueryOptimze() {
            this(1000, null, null, 1000, 100, true);
            /*
             * numScannerCaching=Integer.parseInt((String)globalConfigParams.
             * getParam("hbase.client.scanner.caching"));
             * maxResultSize=Long.parseLong((String)globalConfigParams.getParam(
             * "hbase.client.query.maxResultSize"));
             * batch=Integer.parseInt((String)globalConfigParams.getParam(
             * "hbase.client.query.batch"));
             * enableBlockCache=Boolean.parseBoolean((String)globalConfigParams.
             * getParam("hbase.client.enableBlockCache"));
             */
        }

        public QueryOptimze(int numScannerCaching, long maxResultSize, int batch) {
            this(numScannerCaching, null, null, maxResultSize, batch, false);

        }

        public QueryOptimze(int numScannerCaching, long maxResultSize) {
            this(numScannerCaching, null, null, maxResultSize, -1, false);

        }

        public QueryOptimze(int numScannerCaching, long maxResultSize, boolean enableBlockCache) {
            this(numScannerCaching, null, null, maxResultSize, -1, enableBlockCache);

        }

        public int getNumScannerCaching() {
            return numScannerCaching;
        }

        public void setNumScannerCaching(int numScannerCaching) {
            this.numScannerCaching = numScannerCaching;
        }

        public byte[] getFamilyReturn() {
            return familyReturn;
        }

        public void setFamilyReturn(byte[] familyReturn) {
            this.familyReturn = familyReturn;
        }

        public byte[] getQualifierReturn() {
            return qualifierReturn;
        }

        public void setQualifierReturn(byte[] qualifierReturn) {
            this.qualifierReturn = qualifierReturn;
        }

        public long getMaxResultSize() {
            return maxResultSize;
        }

        public void setMaxResultSize(long maxResultSize) {
            this.maxResultSize = maxResultSize;
        }

        public int getBatch() {
            return batch;
        }

        public void setBatch(int batch) {
            this.batch = batch;
        }

        public boolean isEnableBlockCache() {
            return enableBlockCache;
        }

        public void setEnableBlockCache(boolean enableBlockCache) {
            this.enableBlockCache = enableBlockCache;
        }

   
}
